package com.xunwulian.base.dao;

import com.xunwulian.base.bean.CountSmsByDateEntity;
import com.xunwulian.base.bean.CountSmsByMsisdnEntity;
import com.xunwulian.base.entity.HotestSmsBean;
import com.xunwulian.base.entity.Page;
import com.xunwulian.base.entity.SmsPocessorCountByUserEntity;
import com.xunwulian.base.entity.SmsPocessorEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface SmsPocessorDao {

    int insert(SmsPocessorEntity entity);

    int updateStatus(@Param("status") int status, @Param("seqId") long seqId);

    SmsPocessorEntity getBySeqId(@Param("seqId") long seqId);

    SmsPocessorEntity getLatestSendByMsisdn(@Param("type") int type,
                                            @Param("msisdn") String msisdn);

    // 按照用户查询热门短信
    List<HotestSmsBean> listHotSmsByUserId(@Param("userId") String userId,
                                           @Param("type") int type,
                                           @Param("num") int num);

    // 查询发送频率
    Integer checkFrequence(@Param("userId") String userId,
                           @Param("msisdn") String msisdn,
                           @Param("content") String content,
                           @Param("type") int type,
                           @Param("createTime") Date createTime);

    // 查询所有，分页
    List<SmsPocessorEntity> listPage(@Param("page") Page page,
                                     @Param("appId") String appId,
                                     @Param("userId") String userId,
                                     @Param("msisdnKey") String msisdnKey,
                                     @Param("userNameKey") String userNameKey,
                                     @Param("typeId") Integer typeId);

    // 分用户统计收发短信个数
    List<SmsPocessorCountByUserEntity> listPageStatByUser(@Param("page") Page page,
                                                          @Param("userId") String userId,
                                                          @Param("userName") String userName);

    // APP 短信按照卡分组列表
    List<SmsPocessorEntity> listPageMessageGroup(@Param("page") Page page,
                                                 @Param("userId") String userId);

    List<CountSmsByMsisdnEntity> countSms(@Param("userId") String userId,
                                          @Param("startDate") Date startDate);

    List<CountSmsByDateEntity> countSmsByDay(@Param("userId") String userId,
                                             @Param("startDate") Date startDate);
}
